package com.liuyjy.base.common.desens;

import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector;
import com.liuyjy.base.common.annotations.DataMasking;
import org.springframework.stereotype.Component;

/**
 * @Author liuyjy
 * @Date 2022/7/18 20:45
 * @Description: 拦截器
 **/
@Component
public class DataMaskingIntrospector extends NopAnnotationIntrospector {

    @Override
    public Object findSerializer(Annotated am) {
        DataMasking annotation = am.getAnnotation(DataMasking.class);
        if (annotation != null) {
            return new DataMaskingSerializer(annotation.value().operation());
        }
        return null;
    }
}
